#include "Server/include/HTTP.h"

int HTTP::reuqest(std::shared_ptr<RequestHead>& head){
    if(head->getMethod()=="GET"){  // 如果为get请求，则根据当前请求头中的url中从 urls 获取 处理函数。
        std::shared_ptr<Url> u=urls.getUrl(head->getUrl(),head->args);
        std::shared_ptr<Response> res=u->fun(head);
        std::string resValue=res->returnResponse();
        write(client_fd,resValue.c_str(),resValue.size());
        epoll_ctl(epfd,EPOLL_CTL_DEL,client_fd,event);
        close(client_fd);
    }
    return 0;
}